package com.ivi.car.module.maintain.view.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.SimpleClickListener;
import com.ivi.car.R;
import com.ivi.car.bean.MaintainCarOrderBean;
import com.ivi.car.module.maintain.view.adapter.MaintainCarAdapter;
import com.ivi.car.module.maintain.view.adapter.MaintainCarOrderAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhaolong.han on 2018/3/7. 养车订单
 */

public class OrderFragment extends Fragment implements View.OnClickListener {
  protected Context mContent;
  private TextView tvTodoOrder;
  private RecyclerView mRecyclerView;
  private TextView tvCheckOrder;
  private List<MaintainCarOrderBean> listData = new ArrayList();

  public static OrderFragment newInstance() {
    Bundle args = new Bundle();
    OrderFragment fragment = new OrderFragment();
    fragment.setArguments(args);
    return fragment;
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContent = getContext();
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_maintain_order, null);
    tvTodoOrder = view.findViewById(R.id.tv_todo_order);
    tvCheckOrder = view.findViewById(R.id.tv_check_order);
    mRecyclerView = view.findViewById(R.id.mRecyclerView);
    tvCheckOrder.setOnClickListener(this);
    initData();
    initView();
    return view;
  }

  private void initView() {
    tvTodoOrder.setText(Html.fromHtml("您有<font color='#43b79c'>3</font>个待办订单"));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    MaintainCarOrderAdapter mAdapter = new MaintainCarOrderAdapter();
    mAdapter.setNewData(listData);
    mRecyclerView.setAdapter(mAdapter);

    mRecyclerView.addOnItemTouchListener(new SimpleClickListener() {
      @Override
      public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

      }

      @Override
      public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {

      }

      @Override
      public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

      }

      @Override
      public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {

      }
    });

  }

  private void initData() {
    MaintainCarOrderBean bean1 = new MaintainCarOrderBean();
    bean1.title = "洗车";
    bean1.titleStyle = "待支付";
    bean1.shopName = "车享家新华路店";
    bean1.timeDetail = "2017年3月1日（周日）8:00-9:00";
    listData.add(bean1);

    MaintainCarOrderBean bean2 = new MaintainCarOrderBean();
    bean2.title = "美容";
    bean2.titleStyle = "待确认";
    bean2.shopName = "车享家新华路店";
    bean2.timeDetail = "2017年3月1日（周日）8:00-9:00";
    listData.add(bean2);

    MaintainCarOrderBean bean3 = new MaintainCarOrderBean();
    bean3.title = "维修";
    bean3.titleStyle = "已确认";
    bean3.shopName = "车享家新华路店";
    bean3.timeDetail = "2017年3月1日（周日）8:00-9:00";
    listData.add(bean3);
  }


  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.tv_check_order:

        break;
    }
  }
}
